﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EmailClient.DTO;
using System.Data;
using System.Data.SqlClient;

namespace EmailClient.DAO
{
    class AccountDAO : ConnectDataBase
    {
        public AccountDAO() : base() { }
        public static void AddAccount(Account acc)
        {
            string sql = "insert into Account (EmailAddress, Password, SmtpHost, SmtpPort, Pop3Host, Pop3Port) values ('" + acc.AccountAddress +
                "','" + acc.Password + "','" + acc.SmtpHost + "'," + acc.SmtpPort + ",'" + acc.Pop3Host + "'," + acc.Pop3Port + ")";
            ConnectDataBase.ExcuNonQuery(sql);
        }
        public static DataTable GetAllAccount()
        {
            string sql = "select * from Account";
            return ConnectDataBase.ExcuQuery(sql);
        }
        public static void DeleteAccount(string accAddress)
        {
            string sql = "delete from Account where EmailAddress = '" + accAddress + "'";
            ConnectDataBase.ExcuNonQuery(sql);
        }
        public static DataTable GetAccountByAccountAddress(string accAddress)
        {
            string sql = "select * from Account where EmailAddress = '" + accAddress + "'";
            return ConnectDataBase.ExcuQuery(sql);
        }
    }
}
